<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<t:layout>
    <jsp:body>
    	<div style="padding-left: 120px;">
        <h3><img alt="" src="images/img_group_02.jpg" height="95px" width="269px">設定情報</h3>
		<p id="msg">${msg}</p>
        <form  id="install" action="install/setting">

            <fieldset>
              <legend>CouchBase Server</legend>
                <div class="span12">
                  <label>NODE URL</label>
                  <input type="text"  class="input-xxlarge" name="node_url" placeholder="http://ip address:port/pools" value="${setting.node_url}" required>
                </div>
                <div class="span3">
                  <label>DataBucket For jobs</label>
                  <input type="text" name="databucket_job" placeholder="career...小文字英文" value="${setting.jobBucket}" required>
                </div>
                <div class="span3">
                  <label>DataBucket For keywords</label>
                  <input type="text" name="databucket_keyword" placeholder="keyword...小文字英文" value="${setting.keywordBucket}" required>
                </div>
            </fieldset>
            <fieldset>
                <legend>ElasticSearch</legend>
                <div class="span3">
                  <label>Elasticsearch Index Name</label>
                  <input type="text" name="esCluster" placeholder="jobs...小文字英文" value="${setting.elasticSearchClusterName}">
                </div>
            </fieldset>
            <div class="form-actions">
                <button type="submit" class="btn btn-primary">設定</button>
            </div>
        </form>
        </div>
<script>
$( "#install" ).submit(function( event ) {

	  // Stop form from submitting normally
	  event.preventDefault();

	  // Get some values from elements on the page:
	  var $form = $( this ),
	  node_url = $form.find( "input[name='node_url']" ).val(),
	  databucket_job = $form.find( "input[name='databucket_job']" ).val(),
	  databucket_keyword = $form.find( "input[name='databucket_keyword']" ).val(),
	  esCluster = $form.find( "input[name='esCluster']" ).val(),
	  url = $form.attr( "action" );

	  // Send the data using post
	  var posting = $.post( url, { "node_url": node_url, "databucket_job" :databucket_job,"databucket_keyword":databucket_keyword,"esCluster":esCluster} );

	  // Put the results in a div
	  posting.done(function( data ) {
		  $("#msg").html("<font color='blue'>" + data.msg + "</font>");
		  if(data.msg_error != null && data.msg_error != ""){
			  $("#msg").html("<font color='red'>" + data.msg_error + "</font>");
		  }
	  });
	});
</script>
    </jsp:body>
</t:layout>